package com.apiit.webserviceclient.activities;

import com.apiit.webserviceclient.R;
import com.apiit.webserviceclient.R.id;
import com.apiit.webserviceclient.R.layout;
import com.apiit.webserviceclient.R.menu;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

public class LibraryLoans extends Activity implements OnClickListener {

	EditText patronNo;
	EditText name;
	EditText status;
	EditText exp;
	Button loans;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_library_loans);
		
		Intent intename = getIntent();
		String []value = intename.getStringArrayExtra("array");

		TableLayout table = (TableLayout) findViewById(R.id.tableLayouttest);
		
		for(int i=0;i<value.length-4;i++)
		{
		    TableRow row=new TableRow(this);
		    String titleValue = value[i].replaceAll("&nbsp;", "").replaceAll("\t", "").replaceAll("\n", "").trim();
		    String codeValue = value[i+1].replaceAll("&nbsp;", "").replaceAll("\t", "").replaceAll("\n", "").trim();
		    String burrowedDateValue = value[i+2].replaceAll("&nbsp;", "").replaceAll("\t", "").replaceAll("\n", "").trim();
		    String returnedDateValue = value[i+3].replaceAll("&nbsp;", "").replaceAll("\t", "").replaceAll("\n", "").trim();
		    
		    TextView title=new TextView(this);
		    title.setText(titleValue);
		    title.setTextSize(14);
		   
		    TextView code=new TextView(this);
		    code.setText(codeValue+ "\t");
		    code.setTextSize(14);
		    
		    TextView burrowedDate=new TextView(this);
		    burrowedDate.setText(burrowedDateValue+ "\t");
		    burrowedDate.setTextSize(14);
		   
		    TextView returnedDate=new TextView(this);
		    returnedDate.setText(returnedDateValue+ "\t\n");
		    returnedDate.setTextSize(14);
		    
		    row.addView(title);
		    row.addView(code);
		    row.addView(burrowedDate);
		    row.addView(returnedDate);
		    table.addView(row);
		    i=i+3;
		}


	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.library_loans, menu);
		return true;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub

			

	}

}
